﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Data;

namespace QuanLyKho.DKChung
{
    public partial class XemAnh : Form
    {
        public static string MaID = "0";
        private byte[] _content;

        public XemAnh()
        {
            InitializeComponent();
            LoadData();
        }

        public void LoadData()
        {
            if (MaID != "0")
            {
                var data = DataAll.SelectAll("DkChung_HinhAnh", "*", " WHERE MaAnh=N'" + MaID+"'");
                _content = (byte[])data.Rows[0]["Anh"];
                if (_content != null)
                {
                    Image newImage;
                    using (var ms = new MemoryStream(_content, 0, _content.Length))
                    {
                        ms.Write(_content, 0, _content.Length);
                        newImage = Image.FromStream(ms, true);
                    }

                    pbAnhKho.Image = newImage;
                }
                else
                {
                    pbAnhKho.Image = null;
                }
            }
        }
    }
}
